{extend name="web/public/base" /}
{block name="header"}
<link rel="stylesheet" href="__PUBLIC__/js/fuelux/fuelux.css" type="text/css"/>
<script src="__PUBLIC__/js/fuelux/fuelux.js"></script>
{/block}
{block name="main"}
<section class="scrollable padder">
    <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">管理员</li>
        <li class="active">{$title}</li>
    </ul>
    <div class="row">

        <div class="col-sm-12">
            <div style="margin-top:5px;margin-bottom: 8px;">
                <a type="button" class="btn btn-primary" href="{:url('add')}">新 增</a>
            </div>

            <section class="panel panel-default">
                <header class="panel-heading"> {$title}</header>
                {notempty name="_list"}
                <div class="table-responsive">
                    <table class="table table-striped table-hover b-t b-light text-sm">
                        <thead>
                        <tr>
                            <th>管理员名</th>
                            <th>登录次数</th>
                            <th>最后登录时间</th>
                            <th>最后登录IP</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name='_list' id='vo'}
                        <tr>
                            <td>{$vo.mname}</td>
                            <td>{$vo.login_count}</td>
                            <td>{$vo.last_login_time|date='Y-m-d H:i:s',###}</td>
                            <td>{$vo.last_login_ip}</td>

                            <td>
                                {eq name="vo.status" value="-1"}<span style="color: darkred;">冻结</span>{/eq}
                                {eq name="vo.status" value="1"}<span style="color: green;">正常</span>{/eq}
                            </td>
                            <td>
                                <a class="btn btn-info" href="{:url('updateManager',array('id'=>$vo['mid']))}">编辑</a>
                                {neq name="vo.mid" value="1"}
                                {if condition="$vo['status'] eq 1"}
                                <a class="btn btn-danger" href="javascript:void(0);"
                                   onclick="changeStatus({$vo['mid']},'freeze');">冻结</a>
                                {else/}
                                <a class="btn btn-primary" href="javascript:void(0);"
                                   onclick="changeStatus({$vo['mid']},'unfreeze');">解冻</a>
                                {/if}
                                <a class="btn btn-info"
                                   href="{:url('AuthManager/group',array('mid'=>$vo['mid']))}">添加角色</a>
                                <a class="btn btn-warning" href="#"
                                   onclick="changeStatus({$vo['mid']},'delete');">删除</a>
                                {else/}
                                <button type="button" class="btn btn-default">无</button>
                                {/neq}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <footer class="panel-footer">
                    <div class="row">
                        <div class="text-right text-center-xs">
                            {$page}
                        </div>
                    </div>
                </footer>
                {else/}
                <div style="text-align: center">
                    <image src="__PUBLIC__/images/empty.jpg"></image>
                </div>

                {/notempty}
            </section>
        </div>
    </div>
</section>
{/block}
{block name="footer"}
<script type="text/javascript">
    function changeStatus(mid, type) {
        layer.confirm('确定要进行该操作吗？', function () {
            $.post("{:url('changeStatus')}", {type: type, 'id': mid}, function (data) {
                layer.msg(data.msg);
                location.href = data.url;
            }, 'json');
        })
    }
</script>
{/block}